package group32.server;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public abstract class DBConn {

	public DBConn(){
		
	}
	        Connection conn;

    protected Connection getConn() {

        try {
        	Class.forName("com.mysql.jdbc.Driver");
			String serverName = "fling.seas.upenn.edu";
			String database = "vdurey";
			String url = "jdbc:mysql://" + serverName + "/" + database;
			String user = "vdurey";
			String password = "cis550azerty";
			
			conn = DriverManager.getConnection(url, user, password);
		}
        
        catch (ClassNotFoundException e) {
			  System.out.println("Class not found"); 
			 e.printStackTrace();
			System.exit(1);
		}
        
        catch (SQLException e) {
			System.err.println("Mysql Connection Error: ");
			e.printStackTrace();
			System.exit(1);
		}
        
        if (conn == null)  {
                System.out.println("~~~~~~~~~~ can't get a Mysql connection");
        }
        
        return conn;
}
}
